﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;

namespace MyProject.Tools
{
    public partial class RegexTester : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_Match_Click(object sender, EventArgs e)
        {
            string rule = this.txtbx_rule.Text.Trim();

            Regex reg = new Regex(rule);

            MatchCollection result = reg.Matches(this.txtbx_content.Text.Trim());
            this.lbl_out.Text = "提取结果<br/>";

            foreach (Match ma in result)
            {
                string ss = ma.Groups[1].Value;
                if (!string.IsNullOrEmpty(ss))
                {
                    this.lbl_out.Text += ss + "<br/>";
                }
                else
                {
                    this.lbl_out.Text += "(null)<br/>";
                }
            }
        }
    }
}